#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int singleNumber(vector<int> &nums)
{
    int n = nums.size();
    if (n == 1)
        return nums[0];

    sort(nums.begin(), nums.end());

    for (int i = 0; i < n - 1; i++)
    {
        if (nums[i] == nums[i + 1])
            i += 1;
        else
            return nums[i];
    }
    return nums[n - 1];
}


int main()
{
    vector<int> vi = {4, 1, 2, 1, 2};

    int num = singleNumber(vi);

    cout << num << endl;
}